define(function (require, exports, module) {
	
	function UnredoStack(readerApp) {
		var _readerApp = readerApp,
			_iCurUndoPosition = 0,
			_bMoidified = false,
			_iUsedSize = 0,
			_undoItemStack = [];
			_recordNum = 0;
			
		
		this.addItem = function(unReDoItem){
			_undoItemStack.push(unReDoItem);
			_iCurUndoPosition = _undoItemStack.length;
			_bMoidified = true;
			return true;
		};
		
		this.unDo = function(){
			if (_iCurUndoPosition == 0) return ;
	
			while(_iCurUndoPosition >0){
				_undoItemStack[_iCurUndoPosition - 1].Undo(); 
				_undoItemStack[_iCurUndoPosition -1].setUnDone(true);
				_iCurUndoPosition --;
				if (_undoItemStack[_iCurUndoPosition].getGroup()) break;
			}
			if (_iCurUndoPosition == 0) _bMoidified = false;
		};
		
		this.reDo = function(){
			while(1){
				if (_iCurUndoPosition == _undoItemStack.length) return ;
				_undoItemStack[_iCurUndoPosition ].Redo(); 
				_undoItemStack[_iCurUndoPosition ].setUnDone(false);
				_iCurUndoPosition ++;
				_bMoidified = true;
				if (_iCurUndoPosition >= _undoItemStack.length) break;
				if (_undoItemStack[_iCurUndoPosition].getGroup()) break;
			}
		};
		
		this.removeAll = function(){
			
			_undoItemStack = [];
			_iCurUndoPosition = 0;
			_bMoidified = false;
			_iUsedSize = 0;
		
			return true;
		};
		
		_removeUndoListAt = function(){
			
		};
		
		
		this.getItem = function(index){
			if (index<0 || index>_iCurUndoPosition)
			return null;
			
			var pItem = _undoItemStack[index];
			return pItem;
		}
	}
	
	function UnredoItem(){
		var _type = null,
			_data = null,
			_prior = null,
			_unDone = false,
			_group = true;
			
		this.getType = function(){
			return _type;
		}
		
		this.setUnDone = function(unDone){
			_unDone = unDone;
		}
		
		this.getGroup = function(){
			return _group
		}
		
		this.setData = function(data){
			_data = data;
		}
		
		this.unDo = function(){
			
		}
		
		this.reDo = function(){
			
		}
	}
	
});